          SUBROUTINE (OID,GID,ABORT.PRT,CHECK.ALIGN,LOC.OVRD)
** Version# 11.0002[2] - 12/09/2013 - 02:34pm - TSMITH - eclipse
*** V11.0002 Change - Custom Coding . - 12/09/2013 - TSMITH - eclipse
*** V11.0001 Change - Custom Coding . - 10/29/2013 - TSMITH - eclipse

*** Subroutine: TOE.PRINT.BATCH.ONE
*-------------------------------------------------------------------------*
*** Routine to process a single open transfer. This routine is called in
*** the foreground and background (phantom)
*-------------------------------------------------------------------------*
*** OID       - Ledger record @ID                                  [IN]
*** GID       - Open order generation                              [IN]
*** ABORT.PRT - Boolean flag whether printing was aborted          [OUT]
*** LOC.OVRD  - Default location to use if no other locations      (IN)
***             are found within the location hierarchy
*-------------------------------------------------------------------------*
*** Common Variables: LED, HAJOCA.SITE$, PHANTOM.PROC, JAVA.PROC$
*-------------------------------------------------------------------------*
          * If printing in the foreground from driver the user
          * can abort printing at any point in time when checking
          * the printing alignment. Again this is only when printing in
          * the foreground not in the phantom.
          ABORT.PRT   = NO
     *    CHECK.ALIGN = (NOT(PHANTOM.PROC) AND NOT(JAVA.PROC$))

          IF PHANTOM.PROC OR JAVA.PROC$ THEN
             CHECK.ALIGN = NO
          END

          * Process a single open transfer and print the shipping ticket
          OE.LOCK.LED OID,LOCK.ERR,YES
          IF LOCK.ERR THEN
             * If we were unable to get an exclusive lock then
             * abort. If this is not a phantom process then show the
             * user information about who actually has the lock (User/port)
             IF NOT(PHANTOM.PROC) AND NOT(JAVA.PROC$) THEN
                CHECK.RECORD.LOCK LEDFILE,OID,IS.LOCKED,USER
                USER.MSG = OID:' is locked by ':USER
                WINDOW ,,40,5,3,
                PRINT @(0,1):BELL:USER.MSG
                PRINT @(0,3):'Press <Enter> to Continue : ':
INNADA:         INP A,,,0
                WINDOW.CLOSE
             END
             RETURN
          END

          SV.LOC = LOCATION
          * Set the generation @VM position
          LOCATE GID IN LED(12)<1> SETTING GEN ELSE GOTO FINISH

          * Make sure it is still in an open status
          IF LED(6)<1,GEN> # 'O' THEN GOTO FINISH

          * Determine the printer location
          SHP.BR  = LED(2)<1,GEN,2>
          SHIPVIA = LED(70)<1,GEN>
          PTR.LOC = UT.GET.DFLT.BRANCH.PTR(SHP.BR,SHIPVIA)
          BEGIN CASE
          CASE PTR.LOC
             * If there is a Ship Via Override or a Branch Specific
             * Override use it
             LOCATION = PTR.LOC
          CASE LOC.OVRD
             * If the user specified a location on the driver and
             * the ship via doesn't have an override and there
             * is not a location override at the branch level
             LOCATION = LOC.OVRD
          END CASE

          IF USE.ECLIPSE.FORMS$ THEN
             DOC.ID = 'TRANSFER.SHIPPER'
          END ELSE
             DOC.ID = 'XFER.ORDER'
          END
          PRINTER.FORM.GET DOC.ID,FORM
          SELECT.PTR        PTR.ID,FORM,LOCATION
          IF PTR.ID THEN DFLT.PTR = PTR.ID ELSE
             TRANSFER.MSG  = BELL:'No Ptr!!-Loca:':LOCATION:'-Form:':FORM
             TRANSFER.MSG := '-Order:':OID:' -Skipped'
             IF (PHANTOM.PROC OR JAVA.PROC$) THEN
                PH.STATUS TRANSFER.MSG
             END ELSE
                SEND.MESSAGE 'Phantom',USER.ID,TRANSFER.MSG
             END
             GOTO FINISH
          END

          * Process the shipping generation of the transfer
          SV.PHANTOM.PROC = PHANTOM.PROC
          PHANTOM.PROC    = YES
          OE.PROCESS.ORDER OID,GEN
          PHANTOM.PROC    = SV.PHANTOM.PROC
          PROCESSED       = LED(8)<1,GEN>
          IF NOT(PROCESSED) THEN GOTO FINISH

          * Check if this is a RF inprocess warehouse type
          * and if so see if the order is still inprocess
          NO.PRT = NO
          OE.WHQ.MODE OID,GEN,UPD.WHQ,YES
          IF UPD.WHQ THEN
             SOE.CHECK.INPROCESS NO.PRT,OID,LED(12)<1,GEN>
          END

          * Allow print of Routing Copy
          SHP.BR = LED(2)<1,GEN,2>
          READ BR.REC FROM TERRFILE,SHP.BR THEN
             OSHIPVIA = LED(70)<1,GEN>
             LOCATE OSHIPVIA IN BR.REC<18> SETTING SPOS THEN
                IF BR.REC<22,SPOS> THEN
                   * Print a routing copy
                   STATUS = 'F'
                   SOE.PRINT.ORDER OID,GEN,NUM.PGS,STATUS
                END
             END
          END

          IF NO.PRT THEN
             * If order is still inprocess then log change the status
             * to "Picking". This order will then print once the
             * order is picked and staged on the dock ie. closed.
             STAT   = 'PICKING'
             TMP    = STAT
             TMP<2> = LED(2)<1,GEN,2>
             TMP<3> = DATE()
             TMP<4> = INT(TIME())

             LPOS = DCOUNT(TMP<22>,VM)+1
             LOG.MSG = "Items are inprocess, status updated to ":STAT
             TMP<22,LPOS,1> = "TOE.PH.PRINT.BATCH"
             TMP<22,LPOS,2> = DATE()
             TMP<22,LPOS,3> = INT(TIME())
             TMP<22,LPOS,4> = LOG.MSG
             TMP.ID = OID:'.':LED(12)<1,GEN>"R%4"
             WRITE TMP ON PRVWFILE,TMP.ID
          END ELSE
             IF (PHANTOM.PROC OR JAVA.PROC$) THEN
                TRANSFER.MSG = 'Printing : ':OID
                PH.STATUS TRANSFER.MSG
             END
 BT.CN = LED(1)<1,GEN>
                IF BT.CN = '1' THEN
                PRT.LOC = 'PHAN-WH'
                LOCATIONS = 'PHAN-WH'
                END ELSE
                IF BT.CN = '2' THEN
                PRT.LOC = 'GPS2'
                LOCATIONS = 'GPS2'
                END ELSE
                IF BT.CN = '5564' THEN
                PRT.LOC = 'BR5.COUNTER'
                LOCATIONS = 'BR5.COUNTER'
                END ELSE
                PRT.LOC = ''
                END
                END
                END
                 TOE.PRINT.ORDER.LASER OID,GEN,"S",,,DRPT,,PRT.LOC
                IF JAVA.PROC$ THEN
                   FORM.IDS<-1>  = JAVA.PASSER$<JP.FORM$>
                   DOC.IDS<-1>   = JAVA.PASSER$<JP.DOC.ID$>
                   LOCATIONS<-1> = LOCATION
                END
                RCV.BR = LED(5)<1,GEN>
                IF RCV.BR # '2' THEN
                TOE.PRINT.ORDER.SHIP OID,GEN,"R",,,DRPT,,PRT.LOC
                END
                IF RCV.BR = '2' THEN
                MSG = 'Aight look alive motherfucker! ':OID:' has printed and is on the way!'
                SEND.MESSAGE 'Phantom','JOET',MSG
                END
                *TOE.PRINT.ORDER.SHIP OID,GEN,"R",,,DRPT,,PRT.LOC
                IF JAVA.PROC$ THEN
                   FORM.IDS<-1>  = JAVA.PASSER$<JP.FORM$>
                   DOC.IDS<-1>   = JAVA.PASSER$<JP.DOC.ID$>
                   LOCATIONS<-1> = LOCATION
                END
             IF CHECK.ALIGN THEN GOSUB VERIFY.ALIGN
             BEGIN CASE
             CASE NOT(HAJOCA.SITE$) AND NOT(ABORT.PRT)
                * Hajoca sites manually change print status
                * to 'N' when transfer is ready to be
                * transmitted.
                GOSUB GET.DFLT.PRT.STAT
                OE.UPD.PRINT.STAT OID,GEN,DFLT.PRT.STAT
             CASE HAJOCA.SITE$ AND NOT(ABORT.PRT)
                * Hajoca sites manually change print status
                * to 'N' when transfer is ready to be
                * transmitted. Leave at H
                OE.UPD.PRINT.STAT OID,GEN,'H'
             END CASE
          END
*-------------------------------------------------------------------------*
FINISH:   * Unlock order, restore the users location and return
          OE.UNLOCK.LED OID
          LOCATION = SV.LOC
          RETURN
*-------------------------------------------------------------------------*
GET.DFLT.PRT.STAT:*** Get the default print status.
          *** Note: If you change code in this label check if
          *** TOE.PRINT.BATCH should also be changed.
          DFLT.PRT.STAT = 'N'
          * Use the ship via default print status when valid
          READV PRT.STAT.V FROM SVIAFILE,LED(70)<1,GEN>,10 ELSE
             PRT.STAT.V = ''
          END

          IF PRT.STAT.V # '' THEN
             STAT = LED(6)<1,GEN,1>
             OE.PRT.STATUS.GET OID,GEN,NO,STAT,,PRT.OPTS
             PRT.OPTS.CT = DCOUNT(PRT.OPTS,VM)
             FOR PRT.OPTSX = 1 TO PRT.OPTS.CT
                IF PRT.STAT.V = PRT.OPTS<1,PRT.OPTSX>[1,1] THEN
                   DFLT.PRT.STAT = PRT.STAT.V
                   EXIT
                END
             NEXT PRT.OPTSX
          END
          RETURN
*-------------------------------------------------------------------------*
VERIFY.ALIGN:*** Verfiy the alignment prior to printing the transfer
          WINDOW ,,60,4,3
          PRINT @(0,1):'Verify Form Alignment : '
          PRINT @(10,2):'(<R>eprint, <C>ontinue, <N>ext, <A>bort) : '
IN.ALIGN: PRINT @(24,1):' '
INPALG:   INP ANS,24,1,1,'MCU'
          BEGIN CASE
          CASE ANS = 'R'
             TOE.PRINT.ORDER OID,GEN,,,,,LOC.OVRD
             GOTO IN.ALIGN
          CASE ANS = 'C'
             CHECK.ALIGN = NO
          CASE ANS = 'N'
             NULL
          CASE ANS = 'A'
             ABORT.PRT = YES
          CASE OTHERWISE
             PRINT BELL:
             GOTO IN.ALIGN
          END CASE
          WINDOW.CLOSE
          RETURN
*-------------------------------------------------------------------------*
